import random
print("");

# 1.while循环
num = 5;
while num > 0:
    print(f"num = {num}");
    num -= 1;
print("---------------------------------------\n");

# 2.for循环
str = 'hello world';
size = 0;
for s in str:
    size += 1;
print("变量str的长度为:%d" %size);
print("---------------------------------------\n");

# 3.range(起始值,末尾值, 步长) 返回数字序列
print(type(range(1)));
range(1, 10, 1) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in range(5):
    print(f"i = {i}");
print("---------------------------------------\n");

# 4.break 与 continue
print("猜数字开始!");
target = random.randint(0, 5000);

while True:
    print("请输入你猜测的数字:");
    num = int(input());

    if num == target:
        print("你猜中了,正确数字为:%d" %num);
        break;

    if num > target:
        print("大了");
        continue

    print("小了");
